// pages/company/detail/index.js
const App = getApp();
const AJAX = require("../../../common/request")
const API = require("../../../common/api")
const common = require("../../../common/common")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        navTop: 0,
        navContentHeight: 0,
        placeholderHeight: 0,
        adHeight: 0,
        options: {}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
        this.setData({
            navTop: App.globalData.navTop,
            navContentHeight: App.globalData.navContentHeight,
            UPLOADURL: API.UPLOADURL,
            REQUESTURL: API.REQUESTURL
        })
        const query = wx.createSelectorQuery();
        query.select('.head').boundingClientRect();
        await query.exec((res) => {
            this.setData({
                placeholderHeight: res[0].height,
            })
        });
        AJAX.POST('/system/AppWechat/getbGrouplist', {

        }).then(res => {
            let data = res.rows[0]
            data.groupIntroduction = data.groupIntroduction.replace(/\<img/gi, '<img style="max-width:100%;height:auto"')
            data.groupIntroduction = common.addDomainToImageUrls(data.groupIntroduction, this.data.REQUESTURL)
            data.groupBrandDefinition = data.groupBrandDefinition.replace(/\<img/gi, '<img style="max-width:100%;height:auto"')
            data.groupBrandDefinition = common.addDomainToImageUrls(data.groupBrandDefinition, this.data.REQUESTURL)
            data.groupCorporateCulture = data.groupCorporateCulture.replace(/\<img/gi, '<img style="max-width:100%;height:auto"')
            data.groupCorporateCulture = common.addDomainToImageUrls(data.groupCorporateCulture, this.data.REQUESTURL)
            data.groupCorporateHonors = data.groupCorporateHonors.replace(/\<img/gi, '<img style="max-width:100%;height:auto"')
            data.groupCorporateHonors = common.addDomainToImageUrls(data.groupCorporateHonors, this.data.REQUESTURL)

            console.log(data)
            this.setData({
                options: data
            })
        })
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage(options) {
        // 默认分享配置
        return {
            title: App.globalData.onShareAppMessage.title,
            path: App.globalData.onShareAppMessage.path,
            imageUrl: App.globalData.onShareAppMessage.imageUrl,
        }
    },
    goBack() {
        const pages = getCurrentPages();
        //获取不到上级返回首页
        if (pages.length > 1) {
            wx.navigateBack({})
        } else {
            wx.reLaunch({
                url: '/pages/index/index',
            })
        }
    },
})